import Mock from 'mockjs2'
import { builder } from '../util'

// const username = ['admin', 'super']
// // 强硬要求 ant.design 相同密码
// // '21232f297a57a5a743894a0e4a801fc3',
// const password = ['8914de686ab28dc22f30d3d8e107ff6c', '21232f297a57a5a743894a0e4a801fc3'] // admin, ant.design

// const login = (options) => {
//   const body = getBody(options)
//   console.log('mock: body', body)
//   if (!username.includes(body.userLoginName) || !password.includes(body.pwd)) {
//     return builder({ isLogin: true }, '账户或密码错误', 401)
//   }

//   return builder({
//     data: {
//       token: '4291d7da9005377ec9aec4a71ea837f',
//       type: 'string',
//       userName: 'string'
//     },
//     msg: 'string',
//     status: 'S000'
//   }, '', 200, { 'Custom-Header': Mock.mock('@guid') })
// }

const listOrder = () => {
  const total = 15
  const list = []
  for (var i = 0; i < total; i++) {
    list.push(
      {
        amount: '1234561',
        leapmotorOrderId: `0${i}`,
        leapmotorReceiptNo: '12421432143214321',
        leapmotorReceiptType: '2.00',
        merchantId: '1',
        operatorNo: '2.00',
        payRecordId: '1234561',
        status: '矿泉水 550ml',
        transTime: '12421432143214321'
      }
    )
  }
  return builder({
    'data': {
      'list': list,
      'total': total
    },
    'msg': '成功',
    'status': 'S000'
  })
}

// Mock.mock(/\/login\/login/, 'post', login)
Mock.mock(/\/order\/list_order/, 'get', listOrder)
